package com.example.homemodule.observable;

import java.util.Observable;

public class HomeObservable extends Observable {
    public static final int LIST_SCROLL_TO_TOP = 1;
    public static final int REFRESH_DRUG_FRAGMENT_DATA = 2;
    private static HomeObservable observable = null;

    private HomeObservable() {
    }

    public static HomeObservable getInstance() {
        if (observable == null) {
            synchronized (HomeObservable.class) {
                if (observable == null) {
                    observable = new HomeObservable();
                }
            }
        }
        return observable;
    }

    public void homeDrugListScrollToTop() {
        setChanged();
        notifyObservers(new ObserverBean(LIST_SCROLL_TO_TOP));
    }

    public void refreshDrugFragmentData() {
        setChanged();
        notifyObservers(new ObserverBean(REFRESH_DRUG_FRAGMENT_DATA));
    }

    public static class ObserverBean {
        /**
         * 1:HomeDrugListScrollToTop
         */
        private int type;

        public ObserverBean(int type) {
            this.type = type;
        }

        public int getType() {
            return type;
        }
    }
}
